package com.slow.controller;

import com.alibaba.druid.stat.DruidStatManagerFacade;
import com.slow.entity.Test;
import com.slow.service.impl.TestServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping({"/test"})
public class TestController {
    @Autowired
    private TestServiceImpl testService;

    public TestController() {
    }

    @RequestMapping(
            value = {"peekSql"},
            method = {RequestMethod.GET}
    )
    public int peekSql() {
        List<Test> list = this.testService.list();
        return list.size();
    }

    @RequestMapping(
            value = {"stat"},
            method = {RequestMethod.GET}
    )
    public Object druidStat() {
        return DruidStatManagerFacade.getInstance().getDataSourceStatDataList();
    }
}